package hcn.protocol.ods.report;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import ctd.util.annotation.DicMapping;
import ctd.util.annotation.MappingType;
import ctd.util.xml.jaxb.DateAdapter;
import hcn.protocol.ods.CardBean;
import hcn.protocol.ods.CertificateBean;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * Created by jinxin on 2016/7/16.
 */
@XmlRootElement(name = "labReport")
public class LabHistoryQueryBean implements Serializable{

    private static final long serialVersionUID = 1499197546869319335L;
    private CertificateBean certificate;
    @DicMapping(dic = "cardType&hcn-mpi-dictionary-cardType", innerField = "cardType", type = MappingType.LIST)
    private List<CardBean> cards;
    private String orgId;               //云机构标识
    private Date beginDate;             //开始时间
    private Date endDate;               //结束时间
    private int pageNo;
    private int pageSize;

    public LabHistoryQueryBean() {
    }

    public LabHistoryQueryBean(CertificateBean certificate, List<CardBean> cards, String orgId, Date beginDate, Date endDate, int pageNo, int pageSize) {
        this.certificate = certificate;
        this.cards = cards;
        this.orgId = orgId;
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    @JsonIgnore
    @JsonGetter
    public CertificateBean getCertificate() {
        return certificate;
    }

    public void setCertificate(CertificateBean certificate) {
        this.certificate = certificate;
    }

    @XmlTransient
    public String getCertificateType(){
        return certificate != null ? certificate.getCertificateType() : null;
    }

    @XmlTransient
    public String getCertificateNo(){
        return certificate != null ? certificate.getCertificateNo() : null;
    }

    @XmlTransient
    public String getNationNo(){
        return certificate != null ? certificate.getNationNo() : null;
    }

    @XmlElementWrapper(name = "cards")
    @XmlElement(name = "card")
    public List<CardBean> getCards() {
        return cards;
    }

    public void setCards(List<CardBean> cards) {
        this.cards = cards;
    }

    public String getOrgId() {
        return orgId;
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    @XmlJavaTypeAdapter(DateAdapter.class)
    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    @XmlJavaTypeAdapter(DateAdapter.class)
    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
